package com.xjrsoft.module.base.controller;


import com.xjrsoft.common.result.Response;
import com.xjrsoft.core.tool.utils.BeanUtil;
import com.xjrsoft.module.base.dto.DesktopDto;
import com.xjrsoft.module.base.entity.XjrBaseDesktopschemeinfo;
import com.xjrsoft.module.base.service.IXjrBaseDesktopschemeinfoService;
import com.xjrsoft.module.base.vo.DesktopSchemeInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zwq
 * @since 2021-12-01
 */
@RestController
@RequestMapping("/desktop-schemeinfo")
@Api(value = "/desktop-schemeinfo",tags = "桌面设计")
public class XjrBaseDesktopschemeinfoController {

    @Autowired
    private IXjrBaseDesktopschemeinfoService baseDesktopschemeinfoService;



    @GetMapping("/{id}")
    @ApiOperation(value="根据id获取设计")
    public Response getById(@PathVariable String id){
        return  Response.ok(BeanUtil.copy(baseDesktopschemeinfoService.getById(id), DesktopSchemeInfoVo.class));
    }


    @GetMapping("/history")
    @ApiOperation(value="获取历史记录")
    public Response getHistory(DesktopDto desktopDto){
        return  Response.ok(baseDesktopschemeinfoService.getHistory(desktopDto));
    }

    @PutMapping("/setNew")
    @ApiOperation(value="设置为当前版本")
    public Response setNew(String id){
        return  Response.status(baseDesktopschemeinfoService.setNew(id));
    }


}
